import {formatTime} from './CommonFn.jsx';
//数据源
const weather = ['sunny','cloudy','rainy','stormy'];
const weatherArr = ['晴','多云','雨','雷'];
const windPower = ['东','南','西','北','东南','东北','西南','西北'];
const surname = ['赵','钱','孙','李'];
const nameNum = ['一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六','十七'];
const position = ['系统管理员','分析员','数据管理员','财务','净化员','其他'];
const userAction = ['上传','修改'];
const userIOrD = ['+','-'];
const categories = ['空气', '污染', '水质', '土质'];
const categoriesAction = ['检查','清理','净化'];
const projectAction = ['生活区'];
const color = ['#f56a00','#7adf79','#f56a00','#00a2a6','#3d65a5','#3a5a64','#53a52a'];
export const regionArray = ['生活区A区','生活区B区','生活区C区','商业区A区','商业区B区'];

let newDate = new Date();
let ana =getRandomNumber(0,weather.length-1);

export const adminUser = {user:'admin',name:'李胜',password:'123456',login:false};
//分析页数据
export const analysisJson = {
	weather:{
		weather:weather[ana],
		title:weatherArr[ana],
		temperature:getRandomNumber(0,9)+'℃~'+getRandomNumber(10,30)+'℃',
		windPower:windPower[getRandomNumber(0,windPower.length-1)],
		AQI:getRandomNumber(10,100),
		humidity:getRandomNumber(30,80),
	},
	region:getRandomNumber(0,regionArray.length-1)
}

//分析页数据页数据
export const endexData = [
	{
		key:1,
		name:regionArray[0],
		fraction:80,
		a:90,
		b:70,
		c:85,
		d:75,
		score:[70,73,77,80,72,70,78,80,83,88,83,80],
		ranksId:'ZHS-01',
		user:[
			{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			}
		]
	},{
		key:2,
		name:regionArray[1],
		fraction:75,
		a:90,
		b:60,
		c:80,
		d:75,
		score:[60,63,67,76,65,60,70,63,70,74,77,75],
		ranksId:'ZHS-02',
		user:[
			{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			}
		]
	},{
		key:3,
		name:regionArray[2],
		fraction:70,
		a:80,
		b:50,
		c:65,
		d:60,
		score:[60,56,66,65,62,63,66,66,70,72,73,70],
		ranksId:'ZHS-03',
		user:[
			{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			}
		]
	},{
		key:4,
		name:regionArray[3],
		fraction:64,
		a:75,
		b:50,
		c:67,
		d:67,
		score:[50,55,55,50,55,57,55,60,63,66,65,64],
		ranksId:'ZHS-04',
		user:[
			{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			}
		]
	},{
		key:5,
		name:regionArray[4],
		fraction:60,
		a:70,
		b:50,
		c:70,
		d:70,
		score:[50,55,55,58,60,66,70,64,65,60,62,60],
		ranksId:'ZHS-05',
		user:[
			{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			},{
				name:surname[getRandomNumber(0,3)]+nameNum[getRandomNumber(0,nameNum.length-1)],
				tel:('13'+getRandomNumber(0,9,9)).replace(/,/g,''),
				position:position[getRandomNumber(0,position.length-1)]
			}
		]
	}
]

//监控页数据页数据
export const monitorData = [
	{
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		userAction:userAction[getRandomNumber(0,1)],
		categories:categories[getRandomNumber(0,categories.length-1)],
		userIOrD:userIOrD[getRandomNumber(0,userIOrD.length-1)],
		num:getRandomNumber(1,10),
		date:formatTime(newDate-getRandomNumber(100000,120000),'yyyy-mm-dd hh:ff:ss'),
		ranksId:endexData[analysisJson.region].ranksId
	},{
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		userAction:userAction[getRandomNumber(0,1)],
		categories:categories[getRandomNumber(0,categories.length-1)],
		userIOrD:userIOrD[getRandomNumber(0,userIOrD.length-1)],
		num:getRandomNumber(1,10),
		date:formatTime(newDate-getRandomNumber(150000,180000),'yyyy-mm-dd hh:ff:ss'),
		ranksId:endexData[analysisJson.region].ranksId
	},{
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		userAction:userAction[getRandomNumber(0,1)],
		categories:categories[getRandomNumber(0,categories.length-1)],
		userIOrD:userIOrD[getRandomNumber(0,userIOrD.length-1)],
		num:getRandomNumber(1,10),
		date:formatTime(newDate-getRandomNumber(200000,202000),'yyyy-mm-dd hh:ff:ss'),
		ranksId:endexData[analysisJson.region].ranksId
	},{
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		userAction:userAction[getRandomNumber(0,1)],
		categories:categories[getRandomNumber(0,categories.length-1)],
		userIOrD:userIOrD[getRandomNumber(0,userIOrD.length-1)],
		num:getRandomNumber(1,10),
		date:formatTime(newDate-getRandomNumber(250000,300000),'yyyy-mm-dd hh:ff:ss'),
		ranksId:endexData[analysisJson.region].ranksId
	},{
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		userAction:userAction[getRandomNumber(0,1)],
		categories:categories[getRandomNumber(0,categories.length-1)],
		userIOrD:userIOrD[getRandomNumber(0,userIOrD.length-1)],
		num:getRandomNumber(1,10),
		date:formatTime(newDate-getRandomNumber(300000,310000),'yyyy-mm-dd hh:ff:ss'),
		ranksId:endexData[analysisJson.region].ranksId
	}
];

//项目数据
export const projectData = [
	{
		key:0,
		title:projectAction[getRandomNumber(0,projectAction.length-1)]+categories[getRandomNumber(0,categories.length-1)]+categoriesAction[getRandomNumber(0,categoriesAction.length-1)],
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		user:[
			endexData[analysisJson.region].user[getRandomNumber(0,1)].name,
			endexData[analysisJson.region].user[getRandomNumber(2,3)].name,
			endexData[analysisJson.region].user[getRandomNumber(4,5)].name,
			endexData[analysisJson.region].user[getRandomNumber(6,6)].name
		],
		task:'描述',
		color:color[getRandomNumber(0,color.length-1)],
		initial:'68',
		target:'80',
		startDate:'2018-02-15 12:00:00',
		endDate:'2019-02-15 12:00:00',
		process:getRandomNumber(90,99)[0],
		adopt:true,
		state:0,
		data:[],
		capitalAll:5000,
		capitalIng:3400
	},{
		key:1,
		title:projectAction[getRandomNumber(0,projectAction.length-1)]+categories[getRandomNumber(0,categories.length-1)]+categoriesAction[getRandomNumber(0,categoriesAction.length-1)],
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		user:[
			endexData[analysisJson.region].user[getRandomNumber(0,1)].name,
			endexData[analysisJson.region].user[getRandomNumber(2,3)].name,
			endexData[analysisJson.region].user[getRandomNumber(4,5)].name,
			endexData[analysisJson.region].user[getRandomNumber(6,6)].name
		],
		task:'描述',
		color:color[getRandomNumber(0,color.length-1)],
		initial:'68',
		target:'80',
		startDate:'2018-02-15 12:00:00',
		endDate:'2019-02-15 12:00:00',
		process:getRandomNumber(70,90)[0],
		adopt:true,
		state:0,
		data:[],
		capitalAll:5000,
		capitalIng:3400
	},{
		key:2,
		title:projectAction[getRandomNumber(0,projectAction.length-1)]+categories[getRandomNumber(0,categories.length-1)]+categoriesAction[getRandomNumber(0,categoriesAction.length-1)],
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		user:[
			endexData[analysisJson.region].user[getRandomNumber(0,1)].name,
			endexData[analysisJson.region].user[getRandomNumber(2,3)].name,
			endexData[analysisJson.region].user[getRandomNumber(4,5)].name,
			endexData[analysisJson.region].user[getRandomNumber(6,6)].name
		],
		task:'描述',
		color:color[getRandomNumber(0,color.length-1)],
		initial:'68',
		target:'80',
		startDate:'2018-02-15 12:00:00',
		endDate:'2019-02-15 12:00:00',
		process:getRandomNumber(50,60)[0],
		adopt:true,
		state:0,
		data:[],
		capitalAll:5000,
		capitalIng:3400
	},{
		key:3,
		title:projectAction[getRandomNumber(0,projectAction.length-1)]+categories[getRandomNumber(0,categories.length-1)]+categoriesAction[getRandomNumber(0,categoriesAction.length-1)],
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		user:[
			endexData[analysisJson.region].user[getRandomNumber(0,1)].name,
			endexData[analysisJson.region].user[getRandomNumber(2,3)].name,
			endexData[analysisJson.region].user[getRandomNumber(4,5)].name,
			endexData[analysisJson.region].user[getRandomNumber(6,6)].name
		],
		task:'描述',
		color:color[getRandomNumber(0,color.length-1)],
		initial:'68',
		target:'80',
		startDate:'2018-02-14 12:00:00',
		endDate:'2019-02-14 12:00:00',
		process:getRandomNumber(40,50)[0],
		adopt:true,
		state:0,
		data:[],
		capitalAll:5000,
		capitalIng:3400
	},{
		key:4,
		title:projectAction[getRandomNumber(0,projectAction.length-1)]+categories[getRandomNumber(0,categories.length-1)]+categoriesAction[getRandomNumber(0,categoriesAction.length-1)],
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		user:[
			endexData[analysisJson.region].user[getRandomNumber(0,1)].name,
			endexData[analysisJson.region].user[getRandomNumber(2,3)].name,
			endexData[analysisJson.region].user[getRandomNumber(4,5)].name,
			endexData[analysisJson.region].user[getRandomNumber(6,6)].name
		],
		task:'描述',
		color:color[getRandomNumber(0,color.length-1)],
		initial:'68',
		target:'80',
		startDate:'2018-02-15 12:00:00',
		endDate:'2019-02-15 12:00:00',
		process:getRandomNumber(20,40)[0],
		adopt:true,
		state:0,
		data:[],
		capitalAll:5000,
		capitalIng:3400
	},{
		key:5,
		title:projectAction[getRandomNumber(0,projectAction.length-1)]+categories[getRandomNumber(0,categories.length-1)]+categoriesAction[getRandomNumber(0,categoriesAction.length-1)],
		name:endexData[analysisJson.region].user[getRandomNumber(0,endexData[analysisJson.region].user.length-1)].name,
		user:[
			endexData[analysisJson.region].user[getRandomNumber(0,1)].name,
			endexData[analysisJson.region].user[getRandomNumber(2,3)].name,
			endexData[analysisJson.region].user[getRandomNumber(4,5)].name,
			endexData[analysisJson.region].user[getRandomNumber(6,6)].name
		],
		task:'描述',
		color:color[getRandomNumber(0,color.length-1)],
		initial:'68',
		target:'80',
		startDate:'2018-02-15 12:00:00',
		endDate:'2019-02-15 12:00:00',
		process:getRandomNumber(0,20)[0],
		adopt:true,
		state:0,
		data:[],
		capitalAll:5000,
		capitalIng:3400
	}
];

export const dynamic = [
	{
		name:projectData[0].name,
		action:'新建了',
		title:projectData[0].title,
		date:projectData[0].startDate,
		flag:false,
		key:0
	},{
		name:projectData[1].name,
		action:'新建了',
		title:projectData[1].title,
		date:projectData[1].startDate,
		flag:false,
		key:1
	},{
		name:projectData[2].name,
		action:'新建了',
		title:projectData[2].title,
		date:projectData[2].startDate,
		flag:false,
		key:2
	},{
		name:projectData[3].name,
		action:'新建了',
		title:projectData[3].title,
		date:projectData[3].startDate,
		flag:false,
		key:3
	},{
		name:projectData[4].name,
		action:'新建了',
		title:projectData[4].title,
		date:projectData[4].startDate,
		flag:false,
		key:4
	},{
		name:projectData[5].name,
		action:'新建了',
		title:projectData[5].title,
		date:projectData[5].startDate,
		flag:false,
		key:5
	}
];

export function getTimeMonitorData(action){
	setInterval(() => {
		newDate = new Date();
		monitorData.unshift({
			name:endexData[ana].user[getRandomNumber(0,endexData[ana].user.length-1)].name,
			userAction:userAction[getRandomNumber(0,1)],
			categories:categories[getRandomNumber(0,categories.length-1)],
			userIOrD:userIOrD[getRandomNumber(0,userIOrD.length-1)],
			num:getRandomNumber(1,10),
			date:formatTime(newDate,'yyyy-mm-dd hh:ff:ss'),
			ranksId:endexData[ana].ranksId
		});
		if(monitorData.length > 20){
			monitorData.shift();
		};
		action && action();
	},getRandomNumber(3000,10000))
}

function getRandomNumber(min,max,num) {
	let NumArray = [];
	if(num){
		let i = 0;
		for(i;i<num;i++){
			NumArray.push(parseInt(Math.random()*(max-min+1)+min,10));
		}
	}else{
		NumArray.push(parseInt(Math.random()*(max-min+1)+min,10));
	}
	return NumArray;
}